package com.uobgroup.ews.uam.core.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.uobgroup.ews.uam.core.common.SecurityGroupUtils;
import com.uobgroup.ews.uam.core.dao.AccessToStaffDao;
import com.uobgroup.ews.uam.core.domain.AccessToStaff;

@Service
@Transactional
public class AccessToStaffServiceImpl implements AccessToStaffService {

   @Autowired
   AccessToStaffDao accessToStaffDao;

   public long countAllAccessToStaffs() {
      return accessToStaffDao.count();
   }

   public void deleteAccessToStaff(AccessToStaff accessToStaff) {
      accessToStaffDao.delete(accessToStaff);
   }

   public AccessToStaff findAccessToStaff(Long id) {
      return accessToStaffDao.findOne(id);
   }

   public List<AccessToStaff> findAllAccessToStaffs() {
      return accessToStaffDao.findAll();
   }

   public List<AccessToStaff> findAccessToStaffEntries(int firstResult, int maxResults) {
      return accessToStaffDao.findAll(firstResult, maxResults);
   }

   public void saveAccessToStaff(AccessToStaff accessToStaff) {
      accessToStaff.setSecurityGroup(SecurityGroupUtils.getSecurityGroup(accessToStaff));
      accessToStaffDao.save(accessToStaff);
   }

   public AccessToStaff updateAccessToStaff(AccessToStaff accessToStaff) {
      return accessToStaffDao.update(accessToStaff);
   }
}
